package flatlandRPG;

import org.lwjgl.opengl.GL11;

// -------------------------------------------------------------------------
/**
 * An abstract class for GLObjects made from simple primitives.
 *
 * @author Evan Tatarka (evant)
 * @version Apr 4, 2011
 */
public abstract class GLPrimitive
    extends GLObject
{
    /**
     * The fill draw style for the primitive solid. Displays solid.
     */
    public static final int FILL  = GL11.GL_FILL;
    /**
     * The line draw style for the primitive solid. Displays as a wire frame.
     */
    public static final int LINE  = GL11.GL_LINE;
    /**
     * The point draw style for the primitive solid. Displays as a cloud of
     * points.
     */
    public static final int POINT = GL11.GL_POINT;

    private int             drawStyle;            // The draw style of the
// object


    // ----------------------------------------------------------
    /**
     * Create a new GLPrimitive object.
     */
    public GLPrimitive()
    {
        drawStyle = FILL;
    }


    /**
     * Draws the GLObject
     */
    public void draw()
    {
        GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, drawStyle);
        super.draw();
    }


    /**
     * Returns the draw style of the primitive solid. This can either be FILL,
     * LINE, or POINT.
     *
     * @return the draw style of the primitive solid
     */
    public int getDrawStyle()
    {
        return drawStyle;
    }


    /**
     * Set the draw style of the primitive solid. Valid options are FILL, LINE,
     * or POINT. If the draw style is not valid, the draw style dosn't change.
     *
     * @param drawStyle
     *            the draw style of the primitive solid
     */
    public void setDrawStyle(int drawStyle)
    {
        if (drawStyle == FILL || drawStyle == LINE || drawStyle == POINT)
        {
            this.drawStyle = drawStyle;
        }
    }
}
